package net.zjitc.controller;

import net.zjitc.domain.Order;
import net.zjitc.service.Impl.OrdersServiceImpl;
import net.zjitc.service.OrdersService;
import utils.dispacher.URLMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.SQLException;
import java.util.List;

/**
 * Created by guo on 2017/11/22.
 */
public class OrdersController {
    OrdersService service=new OrdersServiceImpl();
    @URLMapping(url = "/FindAllOrders")
    public String findAll(HttpServletRequest request, HttpServletResponse response) throws SQLException {
        List<Order> orders = service.findAllOrders();
        request.setAttribute("orders",orders);
        return "/admin/orders/list.jsp";
    }
    @URLMapping(url = "/FindOrders")
    public String findOrder(HttpServletRequest request, HttpServletResponse response)
    {
        int state = Integer.valueOf(request.getParameter("state"));
        List<Order> orders = service.findOrders(state);
        request.setAttribute("orders",orders);
        return "/admin/orders/list.jsp";
    }
}
